// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   LogScale.java

package com.java4less.rchart;


// Referenced classes of package com.java4less.rchart:
//			Scale

public class LogScale extends Scale
{

	public double base;

	public LogScale()
	{
		base = 2D;
	}

	public LogScale(int ma, int mi)
	{
		base = 2D;
		max = ma;
		min = mi;
	}

	public int getScreenCoord(double v)
	{
		double logMax = Math.log(max) / Math.log(base);
		double logMin = 0.0D;
		if (min > 0.0D)
			logMin = Math.log(min) / Math.log(base);
		double l;
		if (v > 0.0D)
			l = Math.log(v) / Math.log(base);
		else
			l = 0.0D;
		l -= logMin;
		if (l <= 0.0D)
			l = 0.0D;
		int i = screenMaxMargin - screenMin;
		i = (int)((l * (double)i) / (logMax - logMin));
		if (!reverse)
			i += screenMin;
		else
			i = (screenMax - screenMin - i) + screenMin;
		return i;
	}

	public double getValue(int c)
	{
		if (!reverse)
			c -= screenMin;
		else
			c = screenMax - c;
		double logMax = Math.log(max) / Math.log(base);
		double logMin = 0.0D;
		if (min > 0.0D)
			logMin = Math.log(min) / Math.log(base);
		double i = screenMaxMargin - screenMin;
		double l = ((double)c * (logMax - logMin)) / i;
		l += logMin;
		l = Math.pow(base, l);
		return l;
	}
}
